from django.db import models
from enum import Enum, unique, auto

from wxcloudrun.models import BaseModel


# Create your models here.
class JuqiGood(BaseModel):
    # base info
    name = models.CharField(max_length=100)
    display_url = models.CharField(
        max_length=255,
    )
    # 购买价格
    price = models.PositiveIntegerField(default=999999)
    # 回收价格
    recovery_price = models.PositiveIntegerField(default=0)

    state = models.IntegerField(default=0)

    # sort info
    game_type = models.CharField(max_length=100, default="通用")
    ip_family = models.CharField(max_length=100, default="其他")

    # 赏品等级
    level_title = models.CharField(max_length=100)

    # 是否可以出售
    sale_able = models.BooleanField(default=True)

    # 商品详细介绍
    detail = models.CharField(max_length=240, default="其他")

    class Meta:
        db_table = "JuqiGood"  # table name
        indexes = [
            models.Index(fields=["uuid"]),
            models.Index(fields=["deleted"]),
            models.Index(fields=["createdAt"]),
            models.Index(fields=["name"]),
            models.Index(fields=["game_type"]),
            models.Index(fields=["ip_family"]),
            models.Index(fields=["level_title"]),
        ]
        ordering = ["name"]


@unique
class GoodLevelGameType(Enum):
    quanjushang = auto()
    yifanshang = auto()
    wuxianshang = auto()


class GoodLevel(BaseModel):
    """
    商品等级
    """

    game_type = models.IntegerField(default=1, verbose_name="玩法类型")  # 1全局赏 2一番赏 3无限池 4福利屋
    title = models.CharField(max_length=255, verbose_name="模式标题")  # A赏B赏C赏D赏  全局赏
    desc = models.CharField(max_length=255, verbose_name="玩法说明", null=True)

    method_type = models.IntegerField(
        default=0, verbose_name="玩法模式"
    )  
    # if game_type == 1 0普通商品 1全局赏 2空车赏 3串串赏 4 first赏  5last赏
    # if game_type == 2 0普通赏品 1最终赏
    # if game_type == 3 0普通赏品 1保底商品 3天降神兵 4非酋商品
    # if game_type == 4 0福利赏品

    num = models.IntegerField(default=0, verbose_name="数量")  # 空车*6 or 1串4||1串6

    img_url = models.CharField(max_length=255, verbose_name="赏品图标网络地址")

    class Meta:
        db_table = "GoodLevel"
        indexes = [
            models.Index(fields=["uuid"]),
            models.Index(fields=["deleted"]),
            models.Index(fields=["createdAt"]),
            models.Index(fields=["title"]),
        ]
